<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>结算</title>
<link rel="stylesheet" href="css/balance.css" type="text/css">
</head>
<body>
<div class="header">
<c:set var="user" scope="session" value="${user}"/>
<c:choose>
   <c:when test="${empty user}" >
<div id="header">
<a href="${pageContext.request.contextPath}/home.do">返回首页</a>
<a href="${pageContext.request.contextPath}/home.do">登录</a>
<a href="${pageContext.request.contextPath}/home.do">免费注册</a>
</div>
</c:when>
<c:otherwise>
<div id="header">
<a href="${pageContext.request.contextPath}/home.do">返回首页</a>
<a href="${pageContext.request.contextPath}/my.do">你好${user.nickname }</a>
</div>
</c:otherwise>
</c:choose>
</div>


<div class="assemble">


<div id="address">
<div><label>配送地址</label></div>
<div id="s-address"><label>${waitpay.address }</label></div>
<div>
<div>收件人：${waitpay.account }<label id="phone">${waitpay.phone }</label></div>
</div>
</div>

<div id="service">
<div><label>已选服务</label></div>
   <div id="s-service">
<img src="img/${waitpay.avator }" id="img">
 <div id="ss-service">
    <div id="sss-ser">
<label>${waitpay.goods }</label>
<label id="sum">单价：${waitpay.sum }</label>
    </div>
       <div id="sss-sele">
               <input type="text" id="us-num" value="${waitpay.number}" onclick="insert()">
               <img alt="" src="img/jia.png" id="jia" onclick="changeslie(1)">
               <img alt="" src="img/jian.png" id="jian" onclick="changeslie(-1)">
       </div>
 </div>
  </div>
</div>

<div id="balance">
<div id="b-sum"><label>金额</label></div>
<div id="s-xn"></div>
    <div id="b-xq">
           <div class="miaos"> 商品名称：</label><label class="mias"> ${waitpay.goods_name }</label></div>
         <div class="miaos">  单价：&nbsp;&nbsp;&nbsp;&nbsp;<label class="mias">${waitpay.sum }</label></div>
          <div class="miaos"> 选择件数：<label class="mias" id="miao">${waitpay.number }</label></div>
           <div class="miaos">运费：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label class="mias">0</label></div>
           <div class="miaos">总计：&nbsp;&nbsp;&nbsp;&nbsp;<label class="mias" id="z-sum"> ${waitpay.sum }*${waitpay.number }</label></div>
    </div>
<div id="x-xn"></div>
    <div id="ba-sum">共<input type="text" id="all">元</div>
</div>


<div>
<label>支付方式</label>
 <div id="blank">
 <label><input type="radio" name="checkbox" value="银行卡" checked="checked"><label id="blank-lb">银行卡</label></label>
   <img alt="" src="img/yhk.png" id="yhk">
　　<label><input type="radio" name="checkbox" value="支付宝" ><label id="blank-lb">支付宝</label></label>
   <img alt="" src="img/zfb.png" id="zfb">
 
　　<label><input type="radio" name="checkbox" value="微信"><label id="blank-lb">微信</label></label>
  <img alt="" src="img/wx.png" id="wx">
 
　　<label><input type="radio" name="checkbox" value="余额"><label id="blank-lb">余额</label></label>
   <img alt="" src="img/ye.png" id="ye">
</div>
</div>


<div id="user-zf">
<form action="${pageContext.request.contextPath }/insertorder.do">
<input type="text" name="account" value="${waitpay.account }" id="zaiz">
<input type="text" name="avator" value="${waitpay.avator }" id="zaiz">
<input type="text" name="goods_name" value="${waitpay.goods_name }" id="zaiz">
  <input type="text" name="goods_id" value="${waitpay.goods_id }" id="zaiz">
    <input type="text" name="phone" value="${waitpay.phone }" id="zaiz">
     <input type="text" name="transport" value="${waitpay.address }" id="zaiz">
       <input type="text" name="number" id="zfn">
          <input type="text" name="lump_sum" id="zfl">
<input type="submit" value="立即支付" id="u-zhifu">
</form>
</div>

</div>

<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.11.3.min.js">
</script>
<script type="text/javascript">
var c=${waitpay.sum}*${waitpay.number};
document.getElementById("all").value=c;
document.getElementById("zfn").value=${waitpay.number};
document.getElementById("zfl").value=c;


 var phone=document.getElementById("phone").innerHTML;
 document.getElementById("phone").innerHTML=phone.replace(phone.substring(3,7),"****");

function changeslie(n){
	 var index=parseInt(document.getElementById("us-num").value);
	 var i=parseInt(n);
	 var t=index+i;
	 showslie(t);
}
function showslie(t){
	 if(t<1){
		 document.getElementById("us-num").value=1;
		 document.getElementById("miao").innerHTML=1;
		 document.getElementById("z-sum").innerHTML=${waitpay.sum}+"*"+1;
		 var qs=${waitpay.sum}*1;
		 document.getElementById("all").value=qs;
		 document.getElementById("zfn").value=1;
		 document.getElementById("zfl").value=qs;
			// document.getElementById("show-sum").innerHTML=s*${goods.sum};
	 }
	 //else if (t>${goods.number}){
		// document.getElementById("us-num").value=${goods.number};
		// document.getElementById("show-sum").innerHTML=${goods.number}*${goods.sum};
	// }
	 else{
		 document.getElementById("us-num").value=t;
		 document.getElementById("miao").innerHTML=t;
		 document.getElementById("z-sum").innerHTML=${waitpay.sum}+"*"+t;
		 var qs=${waitpay.sum}*t;
		 document.getElementById("all").value=qs;
		 document.getElementById("zfn").value=t;
		 document.getElementById("zfl").value=qs;
		// document.getElementById("show-sum").innerHTML=t*${goods.sum};
	 }
}
function insert(){
	 var z= document.getElementById("us-num").value;
	// if(z>${goods.number}){
	//	 alert("数量过多");
	//	 document.getElementById("us-num").value=1;
		// document.getElementById("show-sum").innerHTML=${goods.sum};
	// }
	  if(z<1){
		 alert("至少选择一件");
		 document.getElementById("us-num").value=1;
		 document.getElementById("miao").innerHTML=1;
		 document.getElementById("z-sum").innerHTML=${waitpay.sum}+"*"+1;
		 var qs=${waitpay.sum}*1;
		 document.getElementById("all").value=qs;
		 document.getElementById("zfn").value=1;
		 document.getElementById("zfl").value=qs;
		// document.getElementById("show-sum").innerHTML=${goods.sum};
	 }else{
		 document.getElementById("us-num").value=z;
		 document.getElementById("miao").innerHTML=z;
		 document.getElementById("z-sum").innerHTML=${waitpay.sum}+"*"+z;
		 var qs=${waitpay.sum}*z;
		 document.getElementById("all").value=qs;
		 document.getElementById("zfn").value=z;
		 document.getElementById("zfl").value=qs;
	 }
}
</script>
</body>
</html>